package com.bnz.search.controller;

import com.bnz.search.entity.ItemVo;
import com.bnz.search.service.ItemSearch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.util.Map;

@Controller
@RequestMapping
public class SearchController {
    @Autowired
    private ItemSearch itemSearch;

    @GetMapping({"/","/search.html"})
    public String search(Model model, ItemVo vo) throws IOException {

        Map resultMap = itemSearch.search(vo);

        model.addAttribute("resultMap", resultMap);
        model.addAttribute("vo", vo);
        return "search";
    }
}
